//
//  SignerProtocol.swift
//  XHWalletUtils
//
//  Created by xinph on 2020/5/20.
//  Copyright © 2020 xinph. All rights reserved.
//

import Foundation

public protocol SignedResultType {
    /// 签名结果
    var signedTx: String { get set }
    /// 签名哈希
    var txHash: String { get set }
    var wtxID: String? { get set }
}

public protocol SignerProtocol {
    /// 用本地私钥签名
    /// - Parameters:
    ///   - ts: 代签名交易
    ///   - password：密码
    ///   - from: 发起签名的地址
    func signTX(_ ts: TransactionConvertible, password: String, from: AddressConvertible) -> Result<SignedResultType>
}

extension SignerProtocol {
    public func signTX(_ ts: TransactionConvertible, password: String, from: AddressConvertible) -> Result<SignedResultType> {
        return .failure(XHError(abstractSignerUnknow))
    }
}
